/**
 * All rights Reserved, Designed By 溪云阁
 * Copyright:    Copyright(C) 2016-2020
 */

package com.boots.oss;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import com.module.boots.exception.CommonRuntimeException;
import com.module.boots.oss.AliyunOssUtils;
import com.module.boots.oss.FileTypeEnum;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.SneakyThrows;

/**
 * 文件服务接口
 * @author：溪云阁
 * @date：2020年5月17日
 */
@Api(tags = { "OSS服务：文件接口" })
@RestController
@RequestMapping("web/Oss")
public class OssController {

    @Autowired
    private AliyunOssUtils ossUtils;

    /**
     * 上传文件
     * @author 溪云阁
     * @param files
     * @return List<String>
     */
    @ApiOperation(value = "上传文件")
    @PostMapping(value = "/uploadFiles")
    @SneakyThrows(CommonRuntimeException.class)
    public List<String> uploadFiles(@RequestParam("files") MultipartFile[] files) {
        return ossUtils.uploadFile(files, "imgs", FileTypeEnum.IMG);
    }

}
